<template>
<view class="content">
   <swiper class="swiper_container" circular="true" vertical="true" autoplay="true" interval="3000" v-if="msgList.length != 0">
      <block v-for="(item, index) in msgList" :key="index">
         <navigator url=" " open-type="navigate">
            <swiper-item>
               <view class="swiper_item">
                  <image :src="item.avatar"></image>
                  <view>{{item.username}}{{item.total_price}}元拿了{{item.goods_name}}</view>
               </view>
            </swiper-item>
         </navigator>
      </block>
   </swiper>
   <image class="back" :src="img"></image>
   <view class="zzjx">— 正在进行中 —</view>
   <view v-for="(item, index) in shopList" :key="index" class="liebiao">
      <view class="liebiao_one" @tap="detail" :data-id="item.id">
         <image :src="item.img"></image>
         <view class="right">
            <view class="name">{{item.name}}</view>
            <view class="bottom">
               <!-- <view class='aaa'>限量秒杀</view> -->
               <button hover-class="none">正在疯抢中</button>
            </view>
         </view>
      </view>
   </view>
   <view v-if="noshop" class="zanwu">
      <image src="/static/remao_shop/img/noData.png"></image>
      <view>暂无商品</view>
   </view>
   <view class="bai"></view>
   <view class="bottom-bar">
      <view class="left">
         <image src="/static/remao_shop/img/shopr.png"></image>
         <view>砍价商品</view>
      </view>
      <view @tap="mybargain">
         <image src="/static/remao_shop/img/bargainh.png"></image>
         <view>我的砍价</view>
      </view>
   </view>
</view>
</template>

<script>
// hotmall/packageC/bargainirg/bargainirg.js
import api from "../../../api";
var app = getApp();

export default {
  data() {
    return {
      shopList: [],
      img: '',
      noshop: false,
      msgList: []
    };
  },

  components: {},
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (e) {
    console.log(e);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getList();
    this.shopsList();
    this.ggList();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.getList();
    this.shopsList();
    wx.stopPullDownRefresh();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {},
  methods: {
    //公告栏
    ggList: function () {
      app.globalData.request({
        url: api.default.bargain_order_notice,
        header: {
          'content-type': 'application/x-www-form-urlencoded' // 'content-type': 'application/json'

        },
        data: {},
        method: 'POST',
        success: res => {
          console.log(res);
          this.setData({
            msgList: res.list
          });
        }
      });
    },
    //广告、商品列表数据
    getList: function () {
      app.globalData.request({
        // url: 'https://hotmall.shiliucrm.com/api/bargain/goods_list',
        url: api.default.bargainirg,
        header: {
          'content-type': 'application/x-www-form-urlencoded' // 'content-type': 'application/json'

        },
        data: {},
        method: 'POST',
        success: res => {
          console.log(res);
          this.setData({
            shopList: res.underway
          });

          if (res.underway.length == 0) {
            this.setData({
              noshop: true
            });
          }
        }
      });
    },
    //banner
    shopsList: function () {
      app.globalData.request({
        url: api.default.bargainirgselected,
        header: {
          'content-type': 'application/x-www-form-urlencoded' // 'content-type': 'application/json'

        },
        data: {
          id: 58
        },
        method: 'POST',
        success: res => {
          console.log(res);
          this.setData({
            img: res[0].ad_pic
          });
        }
      });
    },
    //商品详情页
    detail: function (e) {
      console.log(e);
      console.log(e.currentTarget.dataset.id);
      wx.navigateTo({
        url: '../bargaindetails/bargaindetails?id=' + e.currentTarget.dataset.id
      });
    },
    //跳转我的砍价列表
    mybargain: function () {
      wx.redirectTo({
        url: '../mybargain/mybargain'
      });
    }
  }
};
</script>
<style>
@import "./bargainirg.css";
</style>